package com.wsoft.portal.controller;

import com.wsoft.portal.enums.RenderTypeEnum;
import com.wsoft.portal.query.module.PortalRecoverQuery;
import com.wsoft.portal.query.module.UserRenderQuery;
import com.wsoft.portal.service.IPortalModuleService;
import com.wsoft.response.ResponseResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @Author z001
 * @Date 2024/12/31 15:37
 */
@RestController
@Tag(name = "用户端-渲染")
@RequestMapping("/portal")
public class PortalUserController {

    @Resource
    private IPortalModuleService moduleService;

    @Operation(summary = "用户-渲染", description = "用户-渲染")
    @PostMapping("/user/render")
    public ResponseResult userRender(@RequestBody @Valid UserRenderQuery query) {
        return ResponseResult.success(moduleService.userRender(query, RenderTypeEnum.USER.getType()));
    }

    @Operation(summary = "组织-渲染", description = "组织-渲染")
    @PostMapping("/org/render")
    public ResponseResult orgRender(@RequestBody @Valid UserRenderQuery query) {
        return ResponseResult.success(moduleService.userRender(query,RenderTypeEnum.ORG.getType()));
    }

    @Operation(summary = "用户-恢复默认", description = "恢复默认")
    @PostMapping("/user/recover")
    public ResponseResult userRecover(@RequestBody @Valid PortalRecoverQuery query) {
        return ResponseResult.success(moduleService.recover(query,RenderTypeEnum.USER.getType()));
    }

    @Operation(summary = "组织-恢复默认", description = "恢复默认")
    @PostMapping("/org/recover")
    public ResponseResult orgRecover(@RequestBody @Valid PortalRecoverQuery query) {
        return ResponseResult.success(moduleService.recover(query,RenderTypeEnum.ORG.getType()));
    }


}
